package com.sirh.dao;

import java.sql.Connection;
import java.sql.DriverManager;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
 
public class ConexionDB {
	

	
    public static Connection getConnection() {
    
    	
        try {
        ///jdbc:sqlserver://127.0.0.1\\SQLEXPRESS;databaseName=SYSABBA;user=apolo-ex;password=199312
        ///com.microsoft.sqlserver.jdbc.SQLServerDriver
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/sirh?user=root&password=");
            FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"Message","!Conexion Establecida..!"));
            return con;
        } catch (Exception ex) {
            System.out.println("Database.getConnection() " + ex.getMessage());
            return null;
        }
    }
 
    public static void close(Connection con) {
        try {
            con.close();
        } catch (Exception ex) {
        }
    }
}